export enum ERRCODE {
  // 客户端错误
  CLIENT_COMM_ERROR = 400100, // 客户端通用错误
  QUERY_ERROR = 400101,

  // 服务器错误
  SERVER_COMM_ERROR = 500100, // 服务器通用错误
  SERVER_ERROR = 500101, // 服务器错误
  DB_ERROR = 500102, // 数据库错误
}

export enum ERRMSG {
  QUERY_ERROR = 'request queries error',
}

export abstract class BaseController {
  ok(data: any = {}) {
    return {
      code: 200,
      msg: 'success',
      data,
    };
  }

  fail(code = ERRCODE.SERVER_COMM_ERROR, error = 'Unknown error') {
    return {
      code,
      msg: 'fail',
      error: error,
    };
  }
}
